<template>
  <div class="D10all">
    <!-- 头 -->
    <div
      class="D10head2"
      onclick="window.history.go(-1)"
    >
      <img src="../assets/img/箭头.png" alt="" />
      <span>普通定投</span>
    </div>
    <!-- 名称、卡号 -->
    <div class="D10name">
      <div class="D10name1">
        <div>基金名称</div>
        <div>{{ name }}</div>
        <div>123456</div>
      </div>
    </div>
    <!-- 金额 -->
    <div class="D10sum">
      <div class="D10name1">
        <div>定投金额</div>
      </div>
      <div class="D10sum1">
        <span>￥</span>
        <input type="text" placeholder="100.00元起" v-model="money" />
      </div>
      <div class="D10sum2">
        <span>手续费率：1.50%</span>
      </div>
    </div>
    <!-- 定投频率 -->
    <div class="D10frequency">
      <div class="D10frequency1">
        <div>定投频率</div>
        <div>
          <span class="D10frequency1_1">每周:</span>
          <input
            type="text"
            placeholder="请输入一周的定投频率"
            v-model="time"
          />
        </div>
      </div>
      <div class="D10frequency1">
        <div>定投截至日期</div>
        <div>
          <input type="text" placeholder="请输入截止日期" v-model="date" />
        </div>
      </div>
    </div>
    <!-- 提交按钮 -->
    <p class="D10btn" @click="yes1">提交</p>
  </div>
</template>

<script>
import { Ordinary } from "../api/OrdinaryInvestment";
// 弹框
import { Notify } from "vant";
export default {
  data() {
    return {
      money: "",
      time: "",
      date: "",
      name: this.$route.params.fundname,
    };
  },
  methods: {
    yes1() {
      Ordinary({
        fund_name: this.name,
        money: this.money,
        after_datetime: this.date,
        weekday: this.time,
      })
        .then((res) => {
          if (res.code == 200) {
            console.log(res);
            Notify({ type: "success", message: "定投成功" });
            this.$router.push({
              name: "funddetails",
              params: {},
            });
          } else {
            Notify({ type: "warning", message: res.msg });
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  components: {
    [Notify.Component.name]: Notify.Component,
  },
  // 过滤器
  //   filters: {
  //     message(val) {
  //       if (val.length <= 10) {
  //         return val;
  //       }
  //       return val.slice(0, 10) + "...";
  //     },
  //   },
};
</script>

<style src="../assets/css/OrdinaryInvestment.css"></style>
